﻿var url = new Url();
var $css = url.GetQueryString("css");
//设置分页信息
var page = new Page();
page.Url = "../Handler/SMSHandler.ashx";
page.Dom = $("#searchArea");
page.type = 6;
page.CallBack = function (data) {
    $("#dataList").empty();
    $.each(data, function (index, item) {
        item.Css = $css;
        $("#SMSTemplete").tmpl(item).appendTo("#dataList");
    });
};
page.GetPageData();
//添加
$(".add").bind("click", function () {
    location.href = "SMSEdit.aspx?css=" + $css;
});
//删除
function del(id) {
    if (confirm("确定要删除该条记录吗？")) {
        $.getJSON(
            "../Handler/SMSHandler.ashx",
            { Id: id, type: 3, _: Math.random() },
            function (result) {
                if (result.Status) {
                    $("#btnSearch").click();
                }
                else {
                    alert(result.Message);
                }
            }
        );
    }
}
//绑定消息
function bindMsg(userName,msg,userId) {
    $("#divUserName").text(userName);
    $("#divMsgContent").text(msg);
    $("#hdUserId").val(userId);
}

$("#btnSend").bind("click", function () {
    var sms = new SMS();
    sms.SendSMS($("#hdUserId").val(), $("#divMsgContent").text());
});


var SMS = function () { };

SMS.prototype = {
    SendSMS: function ($userIdList, $content) {
        $.ajax({
            type: "post",
            url: "../Handler/SMSHandler.ashx",
            dataType: "json",
            data: { UserIdList: $userIdList, Content: $content, type: 11 },
            cache: false,
            complete: function () {
            },
            success: function (data) {
                if (data > 0) {
                    alert("发送成功！");
                }
                else {
                    alert("发送失败！");
                }
            }
        });
    }
}


